<template>
	<div class="category">
		<!-- 切换的点击区域 -->
		<ul class="title-ul">
			<!-- 当点击时间的时候:标题的默认效果切换：选项卡之间也需要切换 -->
			<li  v-for="item in tabs" :key="item.id" :class="{ 'default' : iscur===item.id }" @click="iscur = item.id">
				{{item.name}}
				<span class="default-span"></span>
			</li>
		</ul>
		<!-- 调用两个选项卡子组件 -->
		<CategoryTab1 v-if="iscur === 1"></CategoryTab1>
		<CategoryTab2 v-if="iscur === 2"></CategoryTab2>
	</div>
</template>

<script>
//引入选项卡1
import CategoryTab1 from './CategoryTab1';
//引入选项卡2
import CategoryTab2 from './CategoryTab2';

export default{
	name:'Category',
	components:{
		CategoryTab1,
		CategoryTab2
	},
	data(){
		return{
			tabs:[
				{ id:1 , name:'热门度假' },
				{ id:2 , name:'热门景点' },
			],
			iscur:1,//默认选中第一个标题以及第一个组件
		}
	}
}

</script>

<style>
.category{
	width: 93%;
	margin: 0.5rem auto;
	height: 10.3rem;
}
.category .title-ul{
	height: 1.17rem;
	background-color: #d5d5d5;
	width: 100%;
	border-radius: 0.3rem;
	display: flex;
	align-items: center;
}
.category .title-ul li{
	width: 50%;
	text-align: center;
	line-height: 1.17rem;
	font-size: 0.35rem;
	font-weight: bold;
	border-radius: 0.3rem;
	position: relative;
}
.category .title-ul .default{
	background-color: white;
}
.category .title-ul .default .default-span{
	display: block;
	background-color: gold;
	height: 0.1rem;
	width: 1rem;
	position: absolute;
	left: 39%;
	bottom: 18%;
}
</style>
